<%= javascript_include_tag 'pagination' %>

<div class="line-label">
  <%= page_entries_info(@materials) %>
</div>

<% if @materials.size > 0 %>
  <% paginated_section(@materials, options_will_paginate({:params => {:controller => :materials, :action => :selector_materials_list_from_paginate, :entity_caller_instance => params[:id]||params[:entity_caller_instance], :id => nil, :search_title => params[:search_title], :search_isbn => params[:search_isbn], :search_issn => params[:search_issn]}})) do %>

    <table> <!--style="min-width: 750px; max-width: 750px;"-->
        <thead>
          <tr>
            <th><%= t('activerecord.attributes.material.title')%></th>
            <th><%= t('activerecord.attributes.material.material_type')%></th>
            <th><%= t('activerecord.attributes.material.isbn')%></th>
            <th><%= t('activerecord.attributes.material.issn')%></th>
            <th><%= t('activerecord.attributes.material.price')%></th>
            <th><%=t('title_actions')%></th>
          </tr>
        </thead>
        <tbody>
          <% @materials.each do |material| %>
            <tr>
            <td><%=h material.title %></td>
            <% if  !material.material_type.nil? %>
              <td><%=h material.material_type.description %></td>
            <% else %>
              <td/>
            <% end %>
            <td><%=h material.isbn %></td>
            <td><%=h material.issn %></td>

            <% if  !material.currency.nil? %>
              <% symbol = material.currency.symbol %>
            <% else %>
              <% symbol = "" %>
            <% end %>
            <td><%=h "#{symbol} #{material.price}" %></td>

            <% if session[:entity_caller] == "WISH_LIST" %>
              <%wish_list = @wish_list||params[:entity_caller_instance]%>
              <td class="action"><%= link_to t('btn_add'), wish_list_add_material_path(wish_list, material) %></td>
            <% end %>
            <% if session[:entity_caller] == "GENERAL_NEWS_LETTER" %>
              <%general_news_letter = @general_news_letter||params[:entity_caller_instance]%>
              <td class="action"><%= link_to t('btn_add'), general_news_letter_add_material_path(general_news_letter, material) %></td>
            <% end %>
            </tr>
          <% end %>
         </tbody>
      </table>
  <% end %>
<% end %>
